package com.bsoft.advance.server.config;

import com.bsoft.advance.core.register.RegistryService;
import com.bsoft.advance.core.register.zk.ZookeeperRegistryService;
import com.bsoft.advance.server.processor.RpcServerProcessor;
import com.bsoft.advance.server.transport.NettyServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(RpcServerProperties.class)
public class BeanConfiguration {

    @Autowired
    RpcServerProperties properties;


    @Bean
    NettyServer nettyServer() {
        return new NettyServer();
    }

    @Bean
    RpcServerProcessor rpcServerProcessor() {
        return new RpcServerProcessor();
    }

    @Bean
    RegistryService registryService() {
        return new ZookeeperRegistryService(properties.getRegistryAddr());
    }
}
